package com.along.platform.filterr;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/*
 * @Author: liujinyi
 * @DateTime: 2025/2/20 17:01
 */
@Component
public class CaptchaFilter implements GlobalFilter, Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        ServerHttpRequest request = exchange.getRequest();
        // 拦截登录请求校验验证码
        if (request.getURI().getPath().contains("/login")) {
            String code = request.getQueryParams().getFirst("code");
            String uuid = request.getQueryParams().getFirst("uuid");
            // 验证码校验逻辑...
        }
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
